#include "Sort.h"
void Print(int* nums, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d ", nums[i]);
	}
	printf("\n");
}

void InsertSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 7, 36, 0, 28, 14 ,4,1};

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	InsertSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void ShellSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 7, 100,36, 0, 28, 14 ,4,1 ,11};

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	ShellSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void BubbleSortTest()
{
	int nums[] = { 5, 2, 9, 3, 2,11, 7, 100,36, 0, 28, 14 ,4,1 ,11 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	BubbleSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void HeapSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 7,100, 36, 0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	HeapSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void SelectSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 7,100, 36, 0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	SelectSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void QuickSort1Test()
{
	int nums[] = { 5, 2, 9, 3, 11, 7,100, 36, 0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	QuickSort1(nums, 0,sizeof(nums) / sizeof(nums[0])-1);
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void QuickSort2Test()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	QuickSort2(nums, 0, sizeof(nums) / sizeof(nums[0]) - 1);
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void QuickSortNonRTest()
{
	int nums[] = { 5, 2, 9, 3, 19,53,11, 7,100, 36, 1001,0, 28, 14 ,4,1,71, };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	QuickSortNonR(nums, 0, sizeof(nums) / sizeof(nums[0]) - 1);
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void QuickSort3Test()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	QuickSort3(nums, 0, sizeof(nums) / sizeof(nums[0]) - 1);
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void QuickSort4Test()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	QuickSort4(nums, 0, sizeof(nums) / sizeof(nums[0]) - 1);
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void MergeSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	MergeSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void CountSortTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	CountSort(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}

void MergeSortNonRTest()
{
	int nums[] = { 5, 2, 9, 3, 11, 5,7,100, 36, 5,5,5,0, 28, 14 ,4,1 };
	//int nums[] = { 5, 2, 9, 3, 11, 5,7,100 };
	//int nums[] = { 5, 2, 9, 3, 11, 5,7,100,4,10 };

	Print(nums, sizeof(nums) / sizeof(nums[0]));
	MergeSortNonR(nums, sizeof(nums) / sizeof(nums[0]));
	Print(nums, sizeof(nums) / sizeof(nums[0]));
}
int main()
{
	//InsertSortTest();
	//ShellSortTest();
	//BubbleSortTest();
	//HeapSortTest();
	//SelectSortTest();
	//QuickSort1Test();
	//QuickSort2Test();
	//QuickSortNonRTest();
	//QuickSort3Test();
	//QuickSort4Test();
	//MergeSortTest();
	MergeSortNonRTest();
	//CountSortTest();
	return 0;
}